import "crvpuppet"

define at3_ntpclient($webaddr="", $roleid="") {
  if $AutoMode==true and $CloudCRV==true {
  }
  
  if ( $AutoMode == false ) or ( $AutoMode==true and $CloudCRV==true ) {
    package { "ntp":
      ensure => installed,
    }
    file { "/etc/ntp.conf":
      owner => "root",
      group => "root",
      mode => 644,
      content => template("at3_ntpclient/etc-ntp.conf.tpl"),
    }
    service { "ntpd":
      hasstatus => true,
      hasrestart => true,
      ensure => running,
      enable => true,
      require => [Package["ntp"],File["/etc/ntp.conf"]],
    }
    
#    exec { runntpd:
#      command => "ntpd -q -g",
#      require => File["/etc/ntp.conf"],
#    }
  }
  
  if $AutoMode==true and $CloudCRV==true {
    set_role_attr($webaddr,$roleid,"ProfileApplied","True")
  }
}

define at3_ntpclient_reverse($webaddr, $roleid) {
  set_role_attr($webaddr,$roleid,"ReverseProfileApplied","True")
}

